<?php

namespace App\Store\Controllers\Log;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Store\Models\Sysset\LogDoing;
use App\Store\Models\Sysset\LogLogin;
use App\Common\Services\Store\Common as StoreCommon;

/**
 * 日志信息
 */
class LogController extends Controller
{
   public function getloginlog(Request $request)
   {
      $list = LogLogin::getList($request);
      return response()->json(['code' => '000', 'msg' => '获取成功', 'data' => $list]);
   }

   public function getdoinglog(Request $request)
   {
      $list = LogDoing::getList($request);
      return response()->json(['code' => '000', 'msg' => '获取成功', 'data' => $list]);
   }

   public function delloginlog(Request $request){
      $ids=$request->ids?$request->ids:[];
            
      $ids=is_array($ids)?$ids:json_decode($ids,true);
      
      $cp_id = StoreCommon::getCurrentAccountCompanyId($request);

      if(count($ids)>0){
         LogLogin::where(['cp_id' => $cp_id])->whereIn('id',$ids)->update(['is_del'=>2,'del_at'=>time()]);
      }

      return response()->json(['code' => '000', 'msg' => '操作成功']);

   }

   public function deldoinglog(Request $request){
      $ids=$request->ids?$request->ids:[];
            
      $ids=is_array($ids)?$ids:json_decode($ids,true);
      
      $cp_id = StoreCommon::getCurrentAccountCompanyId($request);

      if(count($ids)>0){
         LogDoing::where(['cp_id' => $cp_id])->whereIn('id',$ids)->update(['is_del'=>2,'del_at'=>time()]);
      }

      return response()->json(['code' => '000', 'msg' => '操作成功']);
   }
}
